package cn.bdqn.controller.order;

import cn.bdqn.service.order.OrderReportFormsService;
import cn.bdqn.service.order.UserOrderService;
import cn.bdqn.utils.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("/api/order")
public class UserOrderController {

    @Autowired
    private UserOrderService orderService;


    @PostMapping
    public Json getOderList(){
        return orderService.getAllRoder();
    }

    @PutMapping("/changeOrderState/{userId}/{ordeStateId}")
    public Json changeOrderState(@PathVariable String userId,@PathVariable Integer ordeStateId){
        return orderService.changeOrderState(userId,ordeStateId);
    }

    @GetMapping("/inser")
    public Json inserOrder(){
       return orderService.getAllRoder();
    }

    @GetMapping("/today")
    public Json getTodayRoder(){
        return orderService.getTodayRoder();
    }
    @GetMapping("/yesterday")
    public Json getYesterDat(){
        return orderService.getYesterDay();
    }
    @GetMapping("/sevenday")
    public Json getSevenDay(){
        return orderService.getSevenDay();
    }
    @DeleteMapping("/deleteAllorder/{orderAll}")
    public Json deleteOrderAll(@PathVariable Integer[] orderAll){
       Boolean b =  orderService.deleteAllOrder(orderAll);
        return Json.ok();
    }
}
